package com.neusoft.controller;

import com.neusoft.entity.Disease;
import com.neusoft.entity.MedicalRecordDisease;
import com.neusoft.service.MedicalRecordDiseaseService;
import com.neusoft.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author akemihomurasama
 */
@RestController
@RequestMapping("/medicalRecordDisease")
@CrossOrigin
public class MedicalRecordDiseaseController {
    @Autowired
    private MedicalRecordDiseaseService medicalRecordDiseaseService;

    /**
     * 保存患者疾病关联信息
     *
     * @param diseaseList     疾病列表
     * @param medicalRecordId 患者病历首页id
     * @return 添加结果
     */
    @RequestMapping("/addDiseaseForPatient/{medicalRecordId}")
    public Result addDiseaseForPatient(@RequestBody List<Disease> diseaseList, @PathVariable("medicalRecordId") int medicalRecordId) {
        return medicalRecordDiseaseService.addDiseaseForPatient(diseaseList, medicalRecordId);
    }

    /**
     * 根据疾病id列表和患者病历首页id批量删除患者疾病
     *
     * @param diseaseIdList 疾病id列表
     * @param recordId      患者病历首页id
     * @return 更新结果
     */
    @RequestMapping("/deleteDiseaseByRecordIdDiseaseId/{recordId}")
    public Result deleteDiseaseByRecordIdDiseaseId(@RequestBody List<Integer> diseaseIdList, @PathVariable("recordId") int recordId) {
        return medicalRecordDiseaseService.deleteDiseaseByRecordIdDiseaseId(diseaseIdList, recordId);
    }
}
